package com.credithc.customers.base.ro;

import com.credithc.customers.base.codes.CustomerCodes;
import com.credithc.customers.base.constants.CustomerConstants;
import com.credithc.customers.base.exception.CustomerException;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

/**
 * @author zhukai
 * @date 2018/11/28 10:55
 */
@Data
public class PreCustomerRo extends CustomerBaseRo {

    private String contactType;

    private String contactInfo;

    private Boolean contactVerified;

    private String associatePreNo;

    private String customerName;

    private String idCardType;

    private String idCardNo;

    private String remark;

    private String password;

    public static void checkBaseParam(PreCustomerRo ro) {
        if (StringUtils.isBlank(ro.getRequestNo())) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "请求流水号不能为空");
        }
        String contactType = ro.getContactType();
        if (StringUtils.isBlank(contactType)) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "注册凭证类型不能为空");
        } else {
            if (!CustomerConstants.CONTACT_TYPE_LIST.contains(contactType)) {
                throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "注册凭证类型不正确，只能是'1','2','3','4'");
            }
        }
        if (StringUtils.isBlank(ro.getContactInfo())) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "注册凭证值不能为空");
        }
    }
}

